#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re
from pathlib import Path

home = Path().home()

file = f'{home}/.zshrc'

with open(file, 'r', encoding='utf-8') as f:
    file_data = f.read()

file_data = re.sub(r'# HYPHEN_INSENSITIVE="true"', 'HYPHEN_INSENSITIVE="true"', file_data)
file_data = re.sub(r"# zstyle ':omz:update' mode disabled", "zstyle ':omz:update' mode disabled", file_data)
file_data = re.sub(r'# export LANG=en_US.UTF-8', 'export LANG=en_US.UTF-8', file_data)
file_data = re.sub(
    r'plugins=\(git\)', 'plugins=(sublime z sudo extract colored-man-pages zsh-autosuggestions zsh-syntax-highlighting)', file_data)
if "conda-zsh-completion" not in file_data:
    file_data = re.sub(r'source \$ZSH/oh-my-zsh.sh',
                       'fpath+=$ZSH/custom/plugins/conda-zsh-completion\nsource $ZSH/oh-my-zsh.sh', file_data)
if "\nalias pyvim" not in file_data:
    file_data += """\nalias pyvim='python3 -c "$(curl -fsSL https://gitee.com/hevey88/brew/raw/master/vim.py)"'"""
if "\nalias pyzsh" not in file_data:
    file_data += """\nalias pyzsh='python3 -c "$(curl -fsSL https://gitee.com/hevey88/brew/raw/master/zshrc.py)"'"""
if "\nalias vi=" not in file_data:
    file_data += "\nalias vi=nvim"
if "\nalias vim=" not in file_data:
    file_data += "\nalias vim=nvim"
if "\nalias goproxy=" not in file_data:
    file_data += "\nalias goproxy='export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890'"
if "\nalias disproxy=" not in file_data:
    file_data += "\nalias disproxy='unset http_proxy https_proxy'"
if "\nalias remove_update=" not in file_data:
    file_data += "\nalias remove_update='defaults write com.apple.systempreferences AttentionPrefBundleIDs 0 && Killall Dock'"
if "\nexport EDITOR=nvim" not in file_data:
    file_data += "\nexport EDITOR=nvim"
with open(file, 'w', encoding='utf-8') as f:
    f.write(file_data)
    f.write("\n")
